package com.qf.controller;

import com.qf.commns.RespData;
import com.qf.pojo.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService service;
    @RequestMapping("/login")
    public RespData loginByName(String userName, String password, HttpSession session){
        RespData login = service.login(userName, password);
        if (login.getCode()==200){
            session.setAttribute("user",login.getData());
        }
        return login;
    }
}
